<?php
$this->pageTitle = 'Manage My Classes';
$this->menu = array(
    array('label' => Yii::t('app', 'Create') . ' ' . $model->label(), 'url' => array('asigntotrainner')),
);
?>

<h3><?php echo Yii::t('app', 'Manage') . ' ' . GxHtml::encode($model->label(2)); ?></h3>

<script type="text/javascript">
    function ChangeStatus(id, status) {
        $.ajax({
            url: "<?php echo $statuschangeurl; ?>",
            type: "post",
            data: "id=" + id + "&status=" + status,
            dataType: "html",
            success: function(msg) {
                $('#classes-grid').yiiGridView.update('classes-grid');
            }
        });

    }
    function gotohome(id, status) {
        $.ajax({
            url: "<?php echo $statuschangegotohome; ?>",
            type: "post",
            data: "id=" + id + "&go_to_home=" + status,
            dataType: "html",
            success: function(msg) {
                $('#classes-grid').yiiGridView.update('classes-grid');
            }
        });

    }
</script>


<?php
$this->widget('zii.widgets.grid.CGridView', array(
    'id' => 'classes-grid',
    'dataProvider' => $DataProvider,
    'filter' => $model,
    //'afterAjaxUpdate' => 'reinstallDatePicker',
    'columns' => array(
        /* 'id', */
        'class_titile',
        array(
            'name' => 'class_type_id',
            'value' => '$data->classType->name',
            'filter' => CHtml::listData(ClassType::model()->findAll(array('condition' => 'status = ' . SkillConfig::STATUS_ACTIVE . ' AND id != 7', 'order' => 'name ASC')), 'id', 'name'),
        ),
//        array(
//            'name' => 'category_id',
//            'value' => '$data->category->name',
//            'filter' => CHtml::listData(Category::model()->findAll(array('condition' => 'status = ' . SkillConfig::STATUS_ACTIVE, 'order' => 'name ASC')), 'id', 'name'),
//        ),
        array(
            'name' => 'class_exp',
            'type' => 'raw',
            'value' => '($data->class_exp!=0)?"Yes":"No"',
            'filter' => array('0' => Yii::t('app', 'No'), '1' => Yii::t('app', 'Yes')),
        ),
        array(
            'name' => 'status',
            'type' => 'raw',
            'value' => 'changeStatusIngridView($data)',
            'filter' => array('0' => Yii::t('app', 'Inactive'), '1' => Yii::t('app', 'Active')),
        ),
         array(
            'name' => 'go_to_home',
            'type' => 'raw',
            'value' => 'gotohomePage($data)',
            'filter' => array('0' => Yii::t('app', 'Inactive'), '1' => Yii::t('app', 'Active')),
        ),
        array(
            'name' => 'backend_user_id',
            'header' => 'Class',
            'value' => 'ClassIngridView($data)',
            'filter' => array(1 => Yii::t('app', 'Backend'), 0 => Yii::t('app', 'Frontend')),
        ),
        array(
            'header' => 'View-Query',
            'value' => 'Classes::checkQueryEmpty($data)',
            'type' => 'raw',
            'filter' => false,
        ),
        array(
            'header' => 'Review-Rating',
            'value' => 'Classes::checkClassesReview($data)',
            'type' => 'raw',
            'filter' => false,
        ),
        array(
            'header' => 'Content-Rate',
            'value' => 'Classes::contentRate($data)',
            'type' => 'raw',
            'filter' => false,
        ),
        array(
            'header' => 'Trainer Suggest',
            'value' => 'Classes::trainersuggest($data)',
            'type' => 'raw',
            'filter' => false,
        ),
        array(
            'class' => 'CButtonColumn',
            'template' => '{view}{update}{delete}',
//            'buttons' => array(
//                'update' => array(
//                    'visible' => 'Classes::showUpdateButtion($data)', //A PHP expression for determining whether the button is visible.
//                ),
//            ),
        ),
    ),
));
//Yii::app()->clientScript->registerScript('re-install-date-picker', "
//function reinstallDatePicker(id, data) {
//    $('#Classes_create_time').datepicker(jQuery.extend(jQuery.datepicker.regional['en-GB'],
//	{'dateFormat':'yy-mm-dd'},{'showOtherMonths':true},{'selectOtherMonths':true},{'changeMonth':true},{'changeYear':true}));
//    $('#Classes_update_time').datepicker(jQuery.extend(jQuery.datepicker.regional['en-GB'],
//	{'dateFormat':'yy-mm-dd'},{'showOtherMonths':true},{'selectOtherMonths':true},{'changeMonth':true},{'changeYear':true}));
//}
//");
?>